home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1996 / MacHack 1996.toast / Presentations / Presentations ’96 / Sessions ’96 / ODF- Easy OpenDoc / MacHack(3) / Sources / Part.cpp < prev    next >
Encoding:
Text File  |  1996-06-18  |  4.2 KB  |  154 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                Part.cpp
  4. //    Release Version:    $ ODF 1 $
  5. //
  6. //    Copyright:            (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #ifndef PART_H
  11. #include "Part.h"
  12. #endif
  13.  
  14. #ifndef DEFINES_K
  15. #include "Defines.k"
  16. #endif
  17.  
  18. #ifndef BINDING_K
  19. #include "Binding.k"
  20. #endif
  21.  
  22. #ifndef FWABOUT_H
  23. #include "FWAbout.h"
  24. #endif
  25.  
  26. // ----- Framework Includes -----
  27.  
  28. #ifndef FWUTIL_H
  29. #include "FWUtil.h"
  30. #endif
  31.  
  32. #ifndef FWCFMRES_H
  33. #include "FWCFMRes.h"
  34. #endif
  35.  
  36. #ifndef FWSHAPE_H
  37. #include "FWShape.h"
  38. #endif
  39.  
  40. //========================================================================================
  41. //    Runtime informations
  42. //========================================================================================
  43.  
  44. #ifdef FW_BUILD_MAC
  45. #pragma segment machack
  46. #endif
  47.  
  48. //========================================================================================
  49. //    CLASS CMacHackPart
  50. //========================================================================================
  51.  
  52.  
  53. FW_DEFINE_AUTO(CMacHackPart)
  54.     
  55. //----------------------------------------------------------------------------------------
  56. //     CMacHackPart::CMacHackPart
  57. //----------------------------------------------------------------------------------------
  58.  
  59. CMacHackPart::CMacHackPart(ODPart* odPart):
  60.     FW_CPart(odPart, FW_gInstance, kPartInfoID),
  61.     fGeometry(cRectangle)
  62. {
  63. }
  64.  
  65. //----------------------------------------------------------------------------------------
  66. //     CMacHackPart::~CMacHackPart
  67. //----------------------------------------------------------------------------------------
  68.  
  69. CMacHackPart::~CMacHackPart()
  70. {
  71. }
  72.  
  73. //----------------------------------------------------------------------------------------
  74. //     CMacHackPart::Initialize
  75. //----------------------------------------------------------------------------------------
  76.  
  77. void CMacHackPart::Initialize(Environment* ev)
  78. {
  79.     FW_CPart::Initialize(ev);
  80.     
  81.     fPresentation = RegisterPresentation(ev, "Apple:Presentation:MacHack", TRUE);
  82.     
  83.     // ----- Initialize my menu -----
  84.     GetMenuBar(ev)->InitializeFromResource(ev, kMenuBar);
  85. }
  86.  
  87. //----------------------------------------------------------------------------------------
  88. //     CMacHackPart::NewFrame
  89. //----------------------------------------------------------------------------------------
  90.  
  91. FW_CFrame* CMacHackPart::NewFrame(Environment* ev, 
  92.                                   ODFrame* odFrame, 
  93.                                   FW_CPresentation* presentation, 
  94.                                   FW_Boolean fromStorage)
  95. {
  96. FW_UNUSED(presentation);
  97. FW_UNUSED(fromStorage);
  98.     
  99.     return FW_NEW(FW_CFrame, (ev, odFrame, presentation, this, kMacHackView));
  100. }
  101.  
  102. //----------------------------------------------------------------------------------------
  103. //     CMacHackPart::NewPartContent
  104. //----------------------------------------------------------------------------------------
  105.  
  106. FW_CContent* CMacHackPart::NewPartContent(Environment* ev)
  107. {
  108.     return NULL;
  109. }
  110.  
  111. //----------------------------------------------------------------------------------------
  112. //    CMacHackPart::DoMenu
  113. //----------------------------------------------------------------------------------------
  114.  
  115. FW_Boolean CMacHackPart::DoMenu(Environment* ev, const FW_CMenuEvent& theMenuEvent)
  116. {
  117.     FW_Boolean result = TRUE;
  118.     ODCommandID commandID = theMenuEvent.GetCommandID(ev);
  119.  
  120.     switch (commandID)
  121.     {
  122.         case kODCommandAbout:
  123.             ::FW_About(ev, this, kAbout);
  124.             break;
  125.         
  126.         case cRectangle:
  127.         case cOval:
  128.         case cRoundRect:
  129.             fGeometry = commandID;
  130.             break;
  131.             
  132.         default:
  133.             result = false;        
  134.     }
  135.     
  136.     return result;
  137. }
  138.  
  139. //----------------------------------------------------------------------------------------
  140. //    CMacHackPart::DoAdjustMenus
  141. //----------------------------------------------------------------------------------------
  142.  
  143. FW_Boolean CMacHackPart::DoAdjustMenus(Environment* ev, FW_CMenuBar* menuBar, FW_Boolean hasMenuFocus, FW_Boolean isRoot)
  144. {
  145.     if (hasMenuFocus)
  146.     {
  147.         menuBar->EnableAndCheckCommand(ev, cRectangle, TRUE, fGeometry == cRectangle);
  148.         menuBar->EnableAndCheckCommand(ev, cOval,  TRUE, fGeometry == cOval);
  149.         menuBar->EnableAndCheckCommand(ev, cRoundRect,  TRUE, fGeometry == cRoundRect);
  150.     }
  151.     
  152.     return false;
  153. }
  154.